package week8;

import lombok.NoArgsConstructor;

/**
 * @author zouran
 * createDate：2024/4/18  15:05
 */
@NoArgsConstructor
public class CalculateSalary {

    public int Getsalary(int myYear, int myMonth) {
        int mySalary, myWorkDays;
        mySalary = 6000;
        myWorkDays = GetWorkDays(myYear, myMonth);
        if (myWorkDays == 31) {
            mySalary = mySalary + 300;
        } else {
            if (myWorkDays == 29) {
                mySalary = mySalary - 100;
            } else {
                if (myWorkDays == 28) {
                    mySalary = mySalary - 150 * 2;
                }
            }
        }
        return mySalary;
    }

    public int GetWorkDays(int myYear, int myMonth) {
        int myWorkDays;
        myWorkDays = 31;
        if (myMonth == 4 || myMonth == 6 || myMonth == 9 || myMonth == 11) {
            myWorkDays = 30;
        } else {
            myWorkDays = 31;
            if (myMonth == 2) {
                if (IsLeap(myYear) == 1) {
                    myWorkDays = 29;
                } else {
                    myWorkDays = 28;
                }
            }
        }
        return myWorkDays;
    }

    public int IsLeap(int year) {
        int leap;
        if (year % 4 == 0) {
            if (year % 100 == 0) {
                leap = 0;
            } else leap = 1;
        } else
            leap = 0;
        if (year % 400 == 0) {
            leap = 1;
        }
        return leap;
    }

}

